package com.rain.controller;

import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;
import com.rain.enums.DateTimePatternEnum;
import com.rain.utils.DateUtil;
import com.rain.enums.PageSize;
import com.rain.query.SimplePage;
import com.rain.query.ResponseVO
import com.rain.entity.SysUnit;
import com.rain.query.SysUnitQuery;
import com.rain.query.PaginationResult;
import com.rain.service.SysUnitService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
/**
 * @auther: rain
 * @description: Controller
 * @date: 2025-10-31
 */

@RestController
@RequestMapping("/sysUnit")
public class SysUnitController extends BaseController {

	@Resource
	private SysUnitService sysUnitService;

	@GetMapping
	public ResponseVO list(SysUnitQuery query) {
		return getSuccessResponseVO(sysUnitService.findListByPage(query));
	}

	/**
	 * 新增
	 */
	@PostMapping
	public ResponseVO add(SysUnit bean) {

	return getSuccessResponseVO(sysUnitService.add(bean));

	}

	/**
	 * 批量新增
	 */
	@PostMapping("/addBatch")
	public ResponseVO addBatch(List<SysUnit> listBean) {

	return getSuccessResponseVO(sysUnitService.addBatch(listBean));

	}

	/**
	 * 批量新增修改
	 */
	@PostMapping("/addOrUpdateBatch")
	public ResponseVO addOrUpdateBatch(List<SysUnit> listBean) {

	return getSuccessResponseVO(sysUnitService.addOrUpdateBatch(listBean));

	}

	/**
	 * 根据Id查询
	 */
	@GetMapping("/{id}")
	public ResponseVO getSysUnitById(@PathVariable Integer id) {

		return getSuccessResponseVO(sysUnitService.getSysUnitById(id));

	}

	/**
	 * 根据Id更新
	 */
	@PutMapping("/{id}")
	public ResponseVO updateSysUnitById(@RequestBody SysUnit bean, @PathVariable Integer id){

		return getSuccessResponseVO(sysUnitService.updateSysUnitById(bean, id));

	}

	/**
	 * 根据Id删除
	 */
	@DeleteMapping("/{id}")
	public ResponseVO deleteSysUnitById(@PathVariable Integer id) {

		return getSuccessResponseVO(sysUnitService.deleteSysUnitById(id));

	}

}